#ifndef _SIEVE_H_
#define _SIEVE_H_

#include "EventProcessor.h"
#include "EventProcessorImp.h"
#include "Message.h"
#include "DistributedCounter.h"
#include "SwapVector.h"

class SieveImp : public EventProcessorImp {

private:

  int max, currentPrime;  
	
  vector<int> primes;

  EventProcessor Filter; 

  // function to help in generating messages
  void SendStream();
 
  void Initialize();  

  SwapVector swapVector;

  SieveImp(int max, EventProcessor& _filter);

  MESSAGE_HANDLER_DECLARATION(Die);	

  MESSAGE_HANDLER_DECLARATION(Done);
	
  friend class Sieve;
};

// Interface class
class Sieve : public EventProcessor {
public:
  Sieve(int max, EventProcessor& _filter);
};

inline Sieve::Sieve(int max, EventProcessor& _filter){
 evProc = new SieveImp(max,_filter);
}

#endif 
